<template>
  <div>
    <button>添加</button>
    <table>
      <thead>
        <tr>
          <th>编号</th>
          <th>类型名称</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <!--注意v-for有可选参数键名和索引(value,key,index)-->
        <tr :key="index" v-for="(item, index) in list">
          <td>
            {{ index + 1 }}
          </td>
          <td>
            {{ item.name }}
          </td>
          <td>
            <button>编辑</button>

            <button>删除</button>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      list: [
        
      ],
    };
  },
  created:function(){
    this.getList();
  },
  methods: {
   
    getList() {
      axios({
        baseURL: "/api",
        method: "get",
        url:"/hometype/search",
    
        // params:{aaaa:1,bbb:2}
      }).then(res => {
        console.info(res);
        this.list=res.data
      });
    },
  },
};
</script>

<style>
table {
  border: 1px solid #e9e9e9;
  border-collapse: collapse;
  border-spacing: 0;
  empty-cells: show;
}
th,
td {
  padding: 8px 16px;
  border: 1px solid #e9e9e9;
  text-align: left;
}
th {
  background: #f7f7f7;
  color: #5c6b77;
  font-weight: 600;
  white-space: nowrap;
}
</style>